package com.photography.controller;


import com.photography.common.Result;
import com.photography.service.AlipayService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/alipay")
public class AlipayController {

    @Resource
    private AlipayService alipayService;

    /**
     * 创建支付订单
     */
    @PostMapping("/create")
    public Result createPayment(@RequestParam Integer orderId) {
        return alipayService.createPayment(orderId);
    }

    /**
     * 支付回调通知
     */
    @PostMapping("/notify")
    public Result handleNotify(
            @RequestParam("trade_status") String tradeStatus,
            @RequestParam("out_trade_no") String outTradeNo,
            @RequestParam("trade_no") String tradeNo) {
        return alipayService.handleNotify(tradeStatus, outTradeNo, tradeNo);
    }

    /**
     * 查询支付结果
     */
    @GetMapping("/query")
    public Result queryPayment(@RequestParam("orderId") String orderId) {
        return alipayService.queryPayment(orderId);
    }
} 